/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package clientFrame;

import ejb.sessions.TDSessionRemote;
import views.ComboBoxCellRender;
import java.util.ArrayList;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.swing.JComboBox;
import models.*;

/**
 *
 * @author simone
 */
public class BookingFrame extends javax.swing.JFrame {

    private PacchettoDTO packet;
    private UserDTO user;
    private ArrayList<hotelDTO> hotels;
    private ArrayList<tourDTO> tours;
    private ArrayList<TripDTO> trips;
    
    private ArrayList<cittaDTO> cities;
    
    /**
     * Creates new form BookPackFrame
     * @param p
     */
    public BookingFrame(PacchettoDTO p) {
        initComponents();
        setPacket(p);
        fillBookFrame();
        setTotale();
        setCellRender();
        availArea.setText("Pacchetto Disponibile\nDal: "+this.packet.getDal()+"\nAl: "+this.packet.getal());
    }
    
    
    
    private void setCellRender()
    {
        ComboBoxCellRender cellRender = new ComboBoxCellRender();
        if(!hotels.isEmpty())
            hotelBox.setRenderer(cellRender);
        if(!tours.isEmpty())
            tourBox.setRenderer(cellRender);
        if(!trips.isEmpty())
            tripBox.setRenderer(cellRender);
        if(!cities.isEmpty())
            cityBox.setRenderer(cellRender);
    }

    private void setPacket(PacchettoDTO p)
    {
        this.packet=p;
    }
    
    public void setUser(UserDTO user)
    {
        this.user=user;
    }
    
    private void fillBookFrame()
    {
        titleLabel.setText(packet.getName());
        descText.setText(packet.getDescription());
        hotels = packet.getSelectedHotels();
        cities = new ArrayList<>();
        cittaDTO currCityHotel;
        hotelDTO hDTO;
        int i=0;
        if(!hotels.isEmpty())
        {   
            hDTO = hotels.get(0);
            currCityHotel = hDTO.getCityHotel();
            cities.add(hDTO.getCityHotel());

            for (i = 1; i < hotels.size(); i++) 
            {
                hDTO = hotels.get(i);
                if(!currCityHotel.getCityName().equalsIgnoreCase(hDTO.getCityHotel().getCityName()))
                {
                    cities.add(hDTO.getCityHotel());
                    currCityHotel = hDTO.getCityHotel();
                }

            }
        }
        tours = packet.getSelectedTours();
        
        /*if(!tours.isEmpty())
        {
            for (tourDTO tDTO : tours) {
                tourBox.addItem(tDTO);
            }
        }*/
        trips = packet.getSelectedTrip();
        /*if(!trips.isEmpty())
        {
            for (TripDTO trDTO : trips) {
                tripBox.addItem(trDTO);
            }
        }*/
        if(!cities.isEmpty())
        {
            for (cittaDTO cDTO : cities) {
                cityBox.addItem(cDTO);
            }
        }
    }
     
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        titleLabel = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        descText = new javax.swing.JTextArea();
        bookBtn = new javax.swing.JButton();
        hotelBox = new javax.swing.JComboBox();
        tourBox = new javax.swing.JComboBox();
        tripBox = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        numPersonField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        bookingDateDal = new javax.swing.JFormattedTextField();
        bookingDateAl = new javax.swing.JFormattedTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        totLabel = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        availArea = new javax.swing.JTextArea();
        errLabel = new javax.swing.JLabel();
        cityBox = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setMaximumSize(new java.awt.Dimension(746, 510));

        titleLabel.setText("Title");

        descText.setEditable(false);
        descText.setColumns(20);
        descText.setLineWrap(true);
        descText.setRows(5);
        descText.setBorder(null);
        jScrollPane1.setViewportView(descText);

        bookBtn.setText("Prenota");
        bookBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bookBtnActionPerformed(evt);
            }
        });

        hotelBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                hotelBoxItemStateChanged(evt);
            }
        });

        tourBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                tourBoxItemStateChanged(evt);
            }
        });

        tripBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                tripBoxItemStateChanged(evt);
            }
        });

        jLabel1.setText("Hotel");

        jLabel2.setText("Escursioni");

        jLabel3.setText("Viaggio");

        jLabel4.setText("numero persone");

        jLabel5.setText("Prenotazione:");

        bookingDateDal.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd/MM/yyyy"))));

        bookingDateAl.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd/MM/yyyy"))));

        jLabel6.setText("dal:");

        jLabel7.setText("al:");

        jLabel8.setText("Totale:");

        availArea.setBackground(new java.awt.Color(238, 238, 238));
        availArea.setColumns(20);
        availArea.setLineWrap(true);
        availArea.setRows(3);
        availArea.setWrapStyleWord(true);
        availArea.setBorder(null);
        jScrollPane2.setViewportView(availArea);

        cityBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cityBoxItemStateChanged(evt);
            }
        });

        jLabel9.setText("Città:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jScrollPane1)
                        .addComponent(titleLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGap(6, 6, 6)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 399, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE))
                                    .addGap(34, 34, 34)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(bookingDateAl, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(bookingDateDal, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(18, 18, 18)
                                            .addComponent(jLabel4)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(numPersonField, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(cityBox, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(37, 37, 37)
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(tripBox, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(8, 8, 8)
                                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 208, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(hotelBox, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup()
                                            .addGap(8, 8, 8)
                                            .addComponent(jLabel2))
                                        .addComponent(tourBox, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(totLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(errLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(bookBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(17, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(hotelBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(45, 45, 45)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tourBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(titleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(7, 7, 7)
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tripBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cityBox))
                        .addGap(16, 16, 16)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(bookingDateDal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(numPersonField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(totLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(bookingDateAl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(26, 26, 26)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(errLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bookBtn)))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bookBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bookBtnActionPerformed
        // TODO add your handling code here:
        
        TDSessionRemote session = lookupTDSessionRemote();
        PrenotatoDTO prenotato = InitializedBookPacket();
        if(prenotato==null)
        {
            errLabel.setText("wrong parameter or missing");
            return;
        }
        boolean booked = session.bookPacket(prenotato);
        availArea.setText("");
        errLabel.setText("");
        this.setVisible(false);
        this.dispose();
        //System.out.println(booked);    
    }//GEN-LAST:event_bookBtnActionPerformed

    private void hotelBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_hotelBoxItemStateChanged
        // TODO add your handling code here:
        //System.out.println("state changed");
        setTotale();
    }//GEN-LAST:event_hotelBoxItemStateChanged

    private void tourBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_tourBoxItemStateChanged
        // TODO add your handling code here:
        setTotale();
    }//GEN-LAST:event_tourBoxItemStateChanged

    private void tripBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_tripBoxItemStateChanged
        // TODO add your handling code here:
        setTotale();
    }//GEN-LAST:event_tripBoxItemStateChanged

    private void cityBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cityBoxItemStateChanged
        // TODO add your handling code here:
        JComboBox cb =  (JComboBox) evt.getSource();
        cittaDTO cDTO = (cittaDTO) cb.getSelectedItem();
        int indexCity = cDTO.getIdCity();
        if (hotels!=null)
        {    
            hotelBox.removeAllItems();
            for (hotelDTO hDTO : hotels) {
                if (hDTO.getCityHotel().getIdCity() == indexCity)
                    hotelBox.addItem(hDTO);
            }
        }
        if(tours!=null)
        {
            tourBox.removeAllItems();
            for (tourDTO tDTO : tours) {
            if(tDTO.getCity().getIdCity()==indexCity)
                tourBox.addItem(tDTO);
            }
        }
        if(trips!=null)
        {       
            tripBox.removeAllItems();
            for(TripDTO trDTO: trips){
                if(trDTO.getCittaDep().getIdCity()==indexCity || trDTO.getCittaArr().getIdCity()==indexCity)
                    tripBox.addItem(trDTO);
            }
        }
    }//GEN-LAST:event_cityBoxItemStateChanged
 
    private void setTotale()
    {
        hotelDTO hotel;
        tourDTO tour;
        TripDTO trip;
        double tot=0;
        int index = hotelBox.getSelectedIndex();
        if(index>=0)
        {
            hotel = hotels.get(index);
            tot+=tot(hotel.getCost());
        }

        index = tourBox.getSelectedIndex();
        if(index>=0)
        {
            tour = tours.get(index);
            tot+=tot(tour.getCost());
        }

        index = tripBox.getSelectedIndex();
        if(index>=0)
        {
            trip = trips.get(index);
            tot+=tot(trip.getCost());
        }

        totLabel.setText("");
        totLabel.setText(Double.toString(tot));
        
    }
    
    private double tot(Object obj){
           
        double costValue;
        if(obj.getClass().toString().equals("class java.lang.Double"))
        {
            Double value = (Double)obj;
            costValue = value.doubleValue();
        }
        else
        {
            Long value = (Long)obj;
            costValue = value.doubleValue();
        }
        return costValue;
    }
    
    
    private PrenotatoDTO InitializedBookPacket()
    {

        Date dal = (Date) bookingDateDal.getValue();
        Date al = (Date) bookingDateAl.getValue(); 
        String numP = numPersonField.getText();
        
        if(numP==null)
            return null;
        
        int num = Integer.parseInt(numP);
        if(num<=0)
        {
            System.out.println("no "+num+" person");
            return null;
        }
        if(dal.compareTo(al)>=0)
            return null;
        
        if(dal==null || al==null)
            return null;
        
        if(dal.before(this.packet.getDal()) || al.after(this.packet.getal()))
            return null;
        
        hotelDTO hotel;
        tourDTO tour;
        TripDTO trip;
        
        PrenotatoDTO prenotato = new PrenotatoDTO(); 
        int index = hotelBox.getSelectedIndex();
        if(index>=0)
        {
            hotel = hotels.get(index);
            prenotato.setHotel(hotel);
        }

        index = tourBox.getSelectedIndex();
        if(index>=0)
        {
            tour = tours.get(index);
            prenotato.setTour(tour);
        }
        
        index = tripBox.getSelectedIndex();
        if(index>=0)
        {
            trip = trips.get(index);
            prenotato.setTrip(trip);
        }

        prenotato.setDal(dal);
        prenotato.setAl(al);
        prenotato.setNum_persone(num);
        prenotato.setPacket(this.packet);
        prenotato.setUser(user);
        
        return prenotato;
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea availArea;
    private javax.swing.JButton bookBtn;
    private javax.swing.JFormattedTextField bookingDateAl;
    private javax.swing.JFormattedTextField bookingDateDal;
    private javax.swing.JComboBox cityBox;
    private javax.swing.JTextArea descText;
    private javax.swing.JLabel errLabel;
    private javax.swing.JComboBox hotelBox;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField numPersonField;
    private javax.swing.JLabel titleLabel;
    private javax.swing.JLabel totLabel;
    private javax.swing.JComboBox tourBox;
    private javax.swing.JComboBox tripBox;
    // End of variables declaration//GEN-END:variables

    private TDSessionRemote lookupTDSessionRemote() {
        try {
            Context c = new InitialContext();
            return (TDSessionRemote) c.lookup("java:comp/env/TDSession");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

}
